Optimal. Leaf size=61 \[ \frac{2 a^2 \tan ^{-1}\left (\frac{a \tan \left (\frac{x}{2}\right )+b}{\sqrt{a^2-b^2}}\right )}{b^2 \sqrt{a^2-b^2}}-\frac{a x}{b^2}-\frac{\cos (x)}{b} \]
[Out]
________________________________________________________________________________________
Rubi [A] time = 0.103534, antiderivative size = 61, normalized size of antiderivative = 1., number of steps used = 6, number of rules used = 6, integrand size = 13, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.462, Rules used = {2746, 12, 2735, 2660, 618, 204} \[ \frac{2 a^2 \tan ^{-1}\left (\frac{a \tan \left (\frac{x}{2}\right )+b}{\sqrt{a^2-b^2}}\right )}{b^2 \sqrt{a^2-b^2}}-\frac{a x}{b^2}-\frac{\cos (x)}{b} \]
Antiderivative was successfully verified.
[In]
[Out]
Rule 2746
Rule 12
Rule 2735
Rule 2660
Rule 618
Rule 204
Rubi steps
\begin{align*} \int \frac{\sin ^2(x)}{a+b \sin (x)} \, dx &=-\frac{\cos (x)}{b}-\frac{\int \frac{a \sin (x)}{a+b \sin (x)} \, dx}{b}\\ &=-\frac{\cos (x)}{b}-\frac{a \int \frac{\sin (x)}{a+b \sin (x)} \, dx}{b}\\ &=-\frac{a x}{b^2}-\frac{\cos (x)}{b}+\frac{a^2 \int \frac{1}{a+b \sin (x)} \, dx}{b^2}\\ &=-\frac{a x}{b^2}-\frac{\cos (x)}{b}+\frac{\left (2 a^2\right ) \operatorname{Subst}\left (\int \frac{1}{a+2 b x+a x^2} \, dx,x,\tan \left (\frac{x}{2}\right )\right )}{b^2}\\ &=-\frac{a x}{b^2}-\frac{\cos (x)}{b}-\frac{\left (4 a^2\right ) \operatorname{Subst}\left (\int \frac{1}{-4 \left (a^2-b^2\right )-x^2} \, dx,x,2 b+2 a \tan \left (\frac{x}{2}\right )\right )}{b^2}\\ &=-\frac{a x}{b^2}+\frac{2 a^2 \tan ^{-1}\left (\frac{b+a \tan \left (\frac{x}{2}\right )}{\sqrt{a^2-b^2}}\right )}{b^2 \sqrt{a^2-b^2}}-\frac{\cos (x)}{b}\\ \end{align*}
Mathematica [A] time = 0.0890538, size = 56, normalized size = 0.92 \[ -\frac{-\frac{2 a^2 \tan ^{-1}\left (\frac{a \tan \left (\frac{x}{2}\right )+b}{\sqrt{a^2-b^2}}\right )}{\sqrt{a^2-b^2}}+a x+b \cos (x)}{b^2} \]
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A] time = 0.033, size = 72, normalized size = 1.2 \begin{align*} -2\,{\frac{1}{b \left ( \left ( \tan \left ( x/2 \right ) \right ) ^{2}+1 \right ) }}-2\,{\frac{\arctan \left ( \tan \left ( x/2 \right ) \right ) a}{{b}^{2}}}+2\,{\frac{{a}^{2}}{{b}^{2}\sqrt{{a}^{2}-{b}^{2}}}\arctan \left ( 1/2\,{\frac{2\,a\tan \left ( x/2 \right ) +2\,b}{\sqrt{{a}^{2}-{b}^{2}}}} \right ) } \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)] time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: ValueError} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A] time = 1.80041, size = 504, normalized size = 8.26 \begin{align*} \left [-\frac{\sqrt{-a^{2} + b^{2}} a^{2} \log \left (\frac{{\left (2 \, a^{2} - b^{2}\right )} \cos \left (x\right )^{2} - 2 \, a b \sin \left (x\right ) - a^{2} - b^{2} + 2 \,{\left (a \cos \left (x\right ) \sin \left (x\right ) + b \cos \left (x\right )\right )} \sqrt{-a^{2} + b^{2}}}{b^{2} \cos \left (x\right )^{2} - 2 \, a b \sin \left (x\right ) - a^{2} - b^{2}}\right ) + 2 \,{\left (a^{3} - a b^{2}\right )} x + 2 \,{\left (a^{2} b - b^{3}\right )} \cos \left (x\right )}{2 \,{\left (a^{2} b^{2} - b^{4}\right )}}, -\frac{\sqrt{a^{2} - b^{2}} a^{2} \arctan \left (-\frac{a \sin \left (x\right ) + b}{\sqrt{a^{2} - b^{2}} \cos \left (x\right )}\right ) +{\left (a^{3} - a b^{2}\right )} x +{\left (a^{2} b - b^{3}\right )} \cos \left (x\right )}{a^{2} b^{2} - b^{4}}\right ] \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F(-1)] time = 0., size = 0, normalized size = 0. \begin{align*} \text{Timed out} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A] time = 1.87935, size = 104, normalized size = 1.7 \begin{align*} \frac{2 \,{\left (\pi \left \lfloor \frac{x}{2 \, \pi } + \frac{1}{2} \right \rfloor \mathrm{sgn}\left (a\right ) + \arctan \left (\frac{a \tan \left (\frac{1}{2} \, x\right ) + b}{\sqrt{a^{2} - b^{2}}}\right )\right )} a^{2}}{\sqrt{a^{2} - b^{2}} b^{2}} - \frac{a x}{b^{2}} - \frac{2}{{\left (\tan \left (\frac{1}{2} \, x\right )^{2} + 1\right )} b} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]